package com.llc.spring.cloud.eureka.client.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * time 2018/6/21 17:45
 *
 * @author xiaojie.zhu <br>
 */
@RestController
public class ApiController {

    @Value("${server.port}")
    private int name;

    @RequestMapping("/hello/{name}")
    public String hello(@PathVariable("name")String name){
        if(1 == 1){
            throw new RuntimeException("12");
        }
        return this.name + " : hello , " + name;
    }

    @RequestMapping("/say/{name}")
    public Map<String,Object> say(@PathVariable("name")String name){
        Map<String,Object> data = new HashMap<>();
        data.put("code",1);
        data.put("data", name);
        return data;
    }

    @RequestMapping("/sayWait")
    public String a() throws InterruptedException {
        Thread.sleep(5000);
        return "wait";
    }
}
